package com.example.pet.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.pet.dao.UserDao;
import com.example.pet.entity.User;
import com.example.pet.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * �û���(User)表服务实现类
 *
 * @author makejava
 * @since 2023-05-12 10:53:02
 */
@Service
public class UserServiceImpl  implements UserService {
    @Resource
    private UserDao userDao;

    @Override
    public User selectOneByNameAndPassword(User user) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_phone",user.getUserPhone());
        return userDao.selectOne(queryWrapper);
    }

    @Override
    public User login(User user) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_phone",user.getUserPhone())
                .eq("password",user.getPassword());
        return userDao.selectOne(queryWrapper);
    }

    @Override
    public boolean add(User user) {
        return userDao.insert(user)>0;
    }

    @Override
    public List<User> AllById() {
        return null;
    }
}

